using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;

namespace ERP.ERPSystem.WarehouseManagement.Dto
{
    /// <summary>
    /// 供应商退货DTO
    /// </summary>
    public class SupplierReturnsDto
    {
        /// <summary>
        /// 主键Id
        /// </summary>
        public int Id { get; set; }

        /// <summary>
        /// 退货单编号
        /// </summary>
        public string ReturnCode { get; set; }

        /// <summary>
        /// 退货单名称
        /// </summary>
        public string ReturnName { get; set; }

        /// <summary>
        /// 采购订单编号
        /// </summary>
        public string ProcurementCode { get; set; }

        /// <summary>
        /// 供应商
        /// </summary>
        public string Vendor { get; set; }

        /// <summary>
        /// 批次号
        /// </summary>
        public string LotNumber { get; set; }

        /// <summary>
        /// 退货日期
        /// </summary>
        public DateTime ReturnDate { get; set; }

        /// <summary>
        /// 退货日期字符串
        /// </summary>
        public string ReturnDateString => ReturnDate.ToString("yyyy-MM-dd");

        /// <summary>
        /// 单据状态
        /// </summary>
        public int DocumentStatus { get; set; }

        /// <summary>
        /// 物料编码（多个编码用逗号分隔）
        /// </summary>
        public string MaterielCode { get; set; }

        /// <summary>
        /// 并发标记
        /// </summary>
        public string ConcurrencyStamp { get; set; }

        /// <summary>
        /// 单据状态显示
        /// </summary>
        public string DocumentStatusDisplay
        {
            get
            {
                return DocumentStatus switch
                {
                    0 => "草稿",
                    1 => "待审核",
                    2 => "已审核",
                    3 => "已完成",
                    4 => "已取消",
                    _ => "未知"
                };
            }
        }

        /// <summary>
        /// 创建时间
        /// </summary>
        public DateTime? CreateTime { get; set; }

        /// <summary>
        /// 修改时间
        /// </summary>
        public DateTime? UpdateTime { get; set; }
    }

    /// <summary>
    /// 供应商退货分页结果
    /// </summary>
    public class SupplierReturnsPagedResult
    {
        /// <summary>
        /// 数据列表
        /// </summary>
        public List<SupplierReturnsDto> Items { get; set; } = new List<SupplierReturnsDto>();

        /// <summary>
        /// 总记录数
        /// </summary>
        public int TotalCount { get; set; }

        /// <summary>
        /// 当前页码
        /// </summary>
        public int PageNumber { get; set; }

        /// <summary>
        /// 每页大小
        /// </summary>
        public int PageSize { get; set; }

        /// <summary>
        /// 总页数
        /// </summary>
        public int TotalPages => (int)Math.Ceiling((double)TotalCount / PageSize);
    }

    /// <summary>
    /// 供应商选择DTO
    /// </summary>
    public class SupplierSelectDto
    {
        /// <summary>
        /// 供应商ID
        /// </summary>
        public int Id { get; set; }

        /// <summary>
        /// 供应商编码
        /// </summary>
        public string SupplierCode { get; set; }

        /// <summary>
        /// 供应商名称
        /// </summary>
        public string SupplierName { get; set; }

        /// <summary>
        /// 供应商简称
        /// </summary>
        public string SupplierNickname { get; set; }

        /// <summary>
        /// 供应商等级
        /// </summary>
        public string SupplierGrade { get; set; }

        /// <summary>
        /// 供应商评分
        /// </summary>
        public int? SupplierScore { get; set; }

        /// <summary>
        /// 供应商联系电话
        /// </summary>
        public string SupplierPhone { get; set; }

        /// <summary>
        /// 是否启用
        /// </summary>
        public int? IsNo { get; set; }

        /// <summary>
        /// 是否启用显示
        /// </summary>
        public string IsEnabledDisplay => IsNo == 1 ? "是" : "否";

        /// <summary>
        /// 备注
        /// </summary>
        public string Context { get; set; }
    }

    /// <summary>
    /// 供应商分页结果
    /// </summary>
    public class SupplierPagedResult
    {
        /// <summary>
        /// 数据列表
        /// </summary>
        public List<SupplierSelectDto> Items { get; set; } = new List<SupplierSelectDto>();

        /// <summary>
        /// 总记录数
        /// </summary>
        public int TotalCount { get; set; }

        /// <summary>
        /// 当前页码
        /// </summary>
        public int PageNumber { get; set; }

        /// <summary>
        /// 每页大小
        /// </summary>
        public int PageSize { get; set; }

        /// <summary>
        /// 总页数
        /// </summary>
        public int TotalPages => (int)Math.Ceiling((double)TotalCount / PageSize);
    }

    /// <summary>
    /// 物料产品选择DTO
    /// </summary>
    public class MaterialProductSelectDto
    {
        /// <summary>
        /// 物料产品ID
        /// </summary>
        public int Id { get; set; }

        /// <summary>
        /// 物料编码
        /// </summary>
        public string MaterielCode { get; set; }

        /// <summary>
        /// 物料名称
        /// </summary>
        public string MaterielName { get; set; }

        /// <summary>
        /// 物料图片
        /// </summary>
        public string MaterielUrl { get; set; }

        /// <summary>
        /// 规格型号
        /// </summary>
        public string Specifications { get; set; }

        /// <summary>
        /// 单位
        /// </summary>
        public string UnitsId { get; set; }

        /// <summary>
        /// 物料/产品类型
        /// </summary>
        public int MaterielTypePid { get; set; }

        /// <summary>
        /// 所属分类
        /// </summary>
        public int MaterielTypeId { get; set; }

        /// <summary>
        /// 是否启用
        /// </summary>
        public int IsNo { get; set; }

        /// <summary>
        /// 是否启用显示
        /// </summary>
        public string IsEnabledDisplay => IsNo == 1 ? "启用" : "禁用";

        /// <summary>
        /// 设置安全库存
        /// </summary>
        public int IsSecure { get; set; }

        /// <summary>
        /// 创建时间
        /// </summary>
        public DateTime CreateTime { get; set; }

        /// <summary>
        /// 创建时间字符串
        /// </summary>
        public string CreateTimeString => CreateTime.ToString("yyyy-MM-dd HH:mm:ss");
    }

    /// <summary>
    /// 物料产品分页结果
    /// </summary>
    public class MaterialProductPagedResult
    {
        /// <summary>
        /// 数据列表
        /// </summary>
        public List<MaterialProductSelectDto> Items { get; set; } = new List<MaterialProductSelectDto>();

        /// <summary>
        /// 总记录数
        /// </summary>
        public int TotalCount { get; set; }

        /// <summary>
        /// 当前页码
        /// </summary>
        public int PageNumber { get; set; }

        /// <summary>
        /// 每页大小
        /// </summary>
        public int PageSize { get; set; }

        /// <summary>
        /// 总页数
        /// </summary>
        public int TotalPages => (int)Math.Ceiling((double)TotalCount / PageSize);
    }
} 